﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SourceCode.Workflow.Client;
using SourceCode.Hosting.Client.BaseAPI;

namespace Eform.Data
{
    public sealed class K2Server
    {
        private static Connection conn = null;
        private static SCConnectionStringBuilder cb = null;

        private static K2Server _instance = null;

        public static K2Server Instance()
        {
            if (_instance == null)
            {
                _instance = new K2Server();
            }
            return _instance;
        }

        private K2Server()
        {
            cb = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
            //cb.Authenticate = true;
            cb.Host = Params.SERVER;
            cb.Integrated = true;
            cb.IsPrimaryLogin = true;
            cb.Port = 5252;

            conn = new Connection();
        }

        public void Open()
        {
            conn.Open(Params.SERVER, cb.ConnectionString);
        }

        public void Close()
        {
            conn.Close();
        }

        public ProcessInstance OpenProcessInstance(int ProcInstID)
        {
            return conn.OpenProcessInstance(ProcInstID);
        }

    }
}
